package com.gds.wiki.cloud.framework.common.utils;


import com.gds.wiki.cloud.framework.common.dto.ResponseDto;
import com.gds.wiki.cloud.framework.common.exception.BizExceptionEnum;

public  class ResponseDtoFactory<T> {

    public static ResponseDtoFactory GetInstance(){

        return new ResponseDtoFactory();
    }

    public ResponseDto<T> build(BizExceptionEnum a){
        ResponseDto t=new ResponseDto();
        t.setCode(a.getCode());
        t.setMesg(a.getMessage());
     return t;
    }

    public ResponseDto<T> build(String code,String mesg){
        ResponseDto t=new ResponseDto();
        t.setCode(code);
        t.setMesg(mesg);
        return t;
    }

    public ResponseDto<T> build(Object data){
        ResponseDto t=new ResponseDto();
        t.setCode(BizExceptionEnum.SUCCESSFUL_OPERATION.getCode());
        t.setMesg(BizExceptionEnum.SUCCESSFUL_OPERATION.getMessage());
        t.setData(data);
        return t;
    }
}
